<?php
$tableUser = 'v1user';

try {
  $hostname = HOST_NAME;
  $username = USER_NAME1;
  $password = PASSWORD1;
  $dbname = DATABASE_NAME1;
  $myPdo = new PDO ('mysql:host=' . $hostname, $username, $password);
  $myPdo->exec('USE ' . $dbname);
  $myPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  $username1 = USER_NAME2;
  $password1 = PASSWORD2;
  $dbname1 = DATABASE_NAME2;
  $myPdo1 = new PDO ('mysql:host=' . $hostname, $username1, $password1);
  $myPdo1->exec('USE ' . $dbname1);
  $myPdo1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
} catch (PDOException $e) {
  echo $e->getMessage ();
}

/**
 *读取一条记录 
 */

function getone($sql,$fetchmethod='')
{
	global $myPdo;
	
    $data = array();
    
    $fetchmethod = empty($fetchmethod) ? PDO::FETCH_OBJ : PDO::FETCH_ASSOC ;	
    $stmt = $myPdo->prepare($sql);
    $stmt->execute();
    if ($stmt->rowCount() == 1) {
      $tmp = $stmt->fetch($fetchmethod);
    }
    
    return $tmp;
    
}

function getone1($sql,$fetchmethod='')
{
	global $myPdo1;
	
    $data = array();
    
    $fetchmethod = empty($fetchmethod) ? PDO::FETCH_OBJ : PDO::FETCH_ASSOC ;	
    $stmt = $myPdo1->prepare($sql);
    $stmt->execute();
    if ($stmt->rowCount() == 1) {
      $tmp = $stmt->fetch($fetchmethod);
    }
    
    return $tmp;
    
}

/*
 * 读取数据并返回对象
 * 
 * */
function getall($sql,$fetchmethod='')
{
	global $myPdo;
	$data = array();
	
	$fetchmethod = empty($fetchmethod) ? PDO::FETCH_OBJ : PDO::FETCH_ASSOC ;
		
    $stmt2 = $myPdo->prepare($sql);
    $stmt2->execute();

    while($tmp2 = $stmt2->fetch($fetchmethod)){
    	/*print_r($tmp2) ;
    	echo "\n";
    	echo "\n";*/
    	
    	foreach(array('date','createdDate','deadline','sentDate','receivedDate','when','cancelledDate','canceldate','operate_date') as $chdate)
    	{
    		//if(empty($fetchmethod)){
	    		if(isset($tmp2->$chdate))
	    		{
		            /*echo $chdate;
		            echo "\n";
		            echo "**************string to object************************";
		            print_r(SimpleDate::fromStamp($tmp2->$chdate));
		            echo "**************string to object************************";
		            echo "\n";*/    			
	    			$tmp2->$chdate = ($tmp2->$chdate != 0) ? SimpleDate::fromStamp($tmp2->$chdate) : NULL;
	    			/*echo "*******转换后的日期:****";
	    			echo "\n";
	    			print_r($tmp2->$chdate);
	    			echo "\n";*/
	    		}
    		//}else{
    			/*print_R($tmp2);
    		    if(isset($tmp2[$chdate]))
                {
                    /*echo $chdate;
                    echo "\n";
                    echo "**************string to object************************";
                    print_r(SimpleDate::fromStamp($tmp2->$chdate));
                    echo "**************string to object************************";
                    echo "\n";*/                
                    //$tmp2[$chdate] = ($tmp2[$chdate] != 0) ? SimpleDate::fromStamp($tmp2[$chdate]) : NULL;
                    /*echo "*******转换后的日期:****";
                    echo "\n";
                    print_r($tmp2->$chdate);
                    echo "\n";*/
                //}*/   			
    			
    		//}
    		
    	}
    	
      	$data[] = $tmp2;
      }

      return $data;
}

function count_num($sql){
	global $myPdo;
	
    $stmt2 = $myPdo->prepare($sql);
    $stmt2->execute();
	
    return $stmt2->rowCount();
}

/**
 * 执行sql
 * */
function sql_execute($sql){
    global $myPdo;	
    
    $stmt2 = $myPdo->prepare($sql);
    $stmt2->execute();

    return;
}


/*
 * 取得下一级的所有数据
 * $utable 表名,$parentId字段名,$e_oid字段的值
 * $condition='' 查询条件 
 * $dasc='' 排序字段
 * */
function getsonall($utable,$parentId,$e_oid,$condition='',$dasc=''){
	global $myPdo;	
	$data = array();
	
	$sql="select *,e_oid as id from ".$utable." where ".$parentId." = '".$e_oid."'";
	
	if(!empty($condition)) $sql .= " and $condition ";
	
	if(!empty($dasc)) $sql .= " order by ".$dasc." ";
	
	//echo $sql;
	
	return getall($sql);
	
}

function lastinsertid(){
	global $myPdo;
	
	return $myPdo->lastInsertId();
}

/**
 *取得下一级的所有e_oid
 *$utable要查询的表,
 *$getfields 需要查询出来的字段,
 *$parentId 查询条件字段,
 *$e_oid 查询的值,
 *$condition=''其他条件,
 *$returnstr='' 返回类似于：1,2,3,4,5这种字符串
 */
 
 function getsonid($utable,$getfields,$parentId,$e_oid,$condition='',$returnstr='')
 {
 	global $myPdo;	
	$data = array();
	$new_data = array();
    
	$sql = " select ".$getfields."  from  ".$utable." where ".$parentId." = '".$e_oid."'  ";
	if(!empty($condition)) $sql .= " and  ".$condition." ";
	
	 $data = getall($sql,1);
	 
		if(empty($returnstr))
		{
		   if(!empty($data))
		   {
                foreach($data as $value)
                {
                    $new_data[] = $value['e_oid'];				
				}				
		      
		     
		     
		   }
		   return $new_data;
		
		
		    return  $data;
		}else{
		    $strid = '';
           	
			if(!empty($data))
			{
			   
			    foreach($data as $value)
				{
				    $strid .= $value['e_oid'].','; 
				}
			    
				$strid = substr($strid,0,-1);
			}
            
            return $strid;			
		
		}
 }

 
 /**
 *取得下一级的所有e_oid
 *$utable要查询的表,
 *$getfields 需要查询出来的字段,
 *$parentId 查询条件字段,
 *$e_oid 查询的值,
 *$condition=''其他条件,
 *$returnstr='' 返回类似于：1,2,3,4,5这种字符串
 */
 
 function getallid($sql,$getfields,$returnstr='',$nosql='')
 {
    global $myPdo;  
    $data = array();
    $new_data = array();
    
    
    if(empty($nosql))
    {
     $data = getall($sql,1);
     
        if(empty($returnstr))
        {
           if(!empty($data))
           {
                foreach($data as $value)
                {
                    $new_data[] = $value[$getfields];              
                }               
              
             
             
           }
           return $new_data;
        
        
            //return  $data;
        }else{
            $strid = '';
            
            if(!empty($data))
            {
               
                foreach($data as $value)
                {
                    $strid .= $value[$getfields].','; 
                }
                
                $strid = substr($strid,0,-1);
            }
            
            return $strid;          
        
        }
    }else{
             $strid = '';
            
            if(!empty($sql))
            {
               
                foreach($sql as $value)
                {
                    $strid .= $value.','; 
                }
                
                $strid = substr($strid,0,-1);
            }
            
            return $strid;       	
    	
    }
 } 
 


          /**
           * 
           * v2_purchaseItems operate
           * 
           */
          function v2_purchaseItems_operate($v2purchaseitem,$debug='')
          {
                foreach ($v2purchaseitem as $v2pitem)
                {
                    if(isset($v2pitem->id) || isset($v2pitem->e_oid))
                    {//update
                        $v2pitemsql ='update ns_producepurchaseitem set ';
                        foreach ($v2pitem as $key => $value)
                        {
                            if(!in_array($key,array('v2_selects','e_oid','id')))
                            {
                               $v2pitemsql .= '`'.$key."`='".addslashes($value)."',";
                            }
                        }
                        
                        $v2pitemsql =substr($v2pitemsql,0,-1);
                        
                        $v2pitemsql .= " where e_oid = '".$v2pitem->e_oid."'";
                        
                        if(!empty($debug))
                        {
                            echo $v2pitemsql."\n";
                        }else{
                            sql_execute($v2pitemsql);
                        }
                        unset($key);
                        unset($value);
                        
                            /**
                             * v2_selects
                             */
                              if(!empty($v2pitem->v2_selects))
                              {
                                  foreach ($v2pitem->v2_selects as $v2ptiemselect)
                                  {
                                     if(isset($v2ptiemselect->id) || isset($v2ptiemselect->e_oid))
                                     {//update
                                        $v2pitemselectsql = "update ns_producepurchaseitemselect set ";
                                        foreach ($v2ptiemselect as $key => $value)
                                        {
                                            if(!in_array($key,array('e_oid','id')))
                                            {
                                               $v2pitemselectsql .= '`'.$key."`='".addslashes($value)."',";
                                            }
                                        }
                                        $v2pitemselectsql =substr($v2pitemselectsql,0,-1);
                                        
                                        $v2pitemselectsql .= " where e_oid = '".$v2ptiemselect->id."'";  

                                        if(!empty($debug))
                                        {
                                            echo $v2pitemselectsql."\n";
                                        }else{
                                            sql_execute($v2pitemselectsql);
                                        }
                                        
                                     }else{//addd
                                        
                                        $v2pitemselectfield = '';
                                        $v2pitemselectvalue = '';
                                        
                                        foreach ($v2ptiemselect as $key => $value)
                                        {
                                            $v2pitemselectfield .='`'.$key.'`,';
                                            $v2pitemselectvalue .= " '".addslashes($value)."',"; 
                                            
                                        }
                                        
                                        $v2pitemselectfield = substr($v2pitemselectfield,0,-1);
                                        $v2pitemselectvalue = substr($v2pitemselectvalue,0,-1);  

                                        $v2pitemselectsql = "insert into ns_producepurchaseitemselect (`e_oid`,".$v2pitemselectfield.") values(NULL,".$v2pitemselectvalue.")";
                                        
                                        if(!empty($debug))
                                        {
                                            echo $v2pitemselectsql."\n";
                                        }else{
                                            sql_execute($v2pitemselectsql);
                                        }
                                     }//end add $v2ptiemselect
                                    
                                     unset($key);
                                     unset($value);
                                  }
                                
                                
                              }//not null
                              
                    }else{//purchaseitemadd
                        
                        $v2pitemfield = '';
                        $v2pitemvalue = '';
                        
                        foreach ($v2pitem as $key => $value)
                        {
                        	if(!in_array($key,array('v2_selects','selects','notes','_added','cancelled','isFree','urgent','order_id')))
                        	{
                        		$v2pitemfield .='`'.$key.'`,';
                                $v2pitemvalue .= " '".addslashes($value)."',"; 
                        	}
                        }
                        
                        $v2pitemfield = substr($v2pitemfield,0,-1);
                        $v2pitemvalue = substr($v2pitemvalue,0,-1);

                        $v2pitemsql = "insert into ns_producepurchaseitem(`e_oid`,".$v2pitemfield.") values(NULL,".$v2pitemvalue.")";  

                        if(!empty($debug))
                        {
                            echo $v2pitemsql."\n";
                        }else{
                            sql_execute($v2pitemsql);
                        }
                           unset($key);
                           unset($value);
                            /**
                             * $v2ptiemselect add
                             */
                             if(!empty($v2pitem->v2_selects))
                             {
                             	foreach ($v2pitem->v2_selects as $v2pitemselect)
                             	{
	                                $v2pitemselectfield = '';
	                                $v2pitemselectvalue = '';
	                                
	                                foreach ($v2pitemselect as $key => $value)
	                                {
	                                	if(!in_array($key,array('purchaseitem_id')))
	                                	{
	                                		$v2pitemselectfield .='`'.$key.'`,';
	                                		$v2pitemselectvalue .= " '".addslashes($value)."',";
	                                	}
	                                    
	                                }
	                                
	                                $v2pitemselectfield = substr($v2pitemselectfield,0,-1);
	                                $v2pitemselectvalue = substr($v2pitemselectvalue,0,-1);
	
	                                $v2pitemselectsql = "insert into ns_producepurchaseitemselect(`e_oid`,".$v2pitemselectfield.") values(NULL,".$v2pitemselectvalue.")";    
	
	                                if(!empty($debug))
	                                {
	                                    echo $v2pitemselectsql."\n";
	                                }else{
	                                    sql_execute($v2pitemselectsql);
	                                }
	                                unset($key);
	                                unset($value);
                                
                             	}//one v2purchaseitemselect
                             	
                             }//end v2purchaseitemselect add
                        
                    }//end purchaseitemadd
                    
                }           
            
          }



function sendEmailOperate($to,$title,$content)
{
  require_once dirname(__FILE__) . '/../library/phpMailer/class.phpmailer.php';

  $mailer = new PHPMailer();
  $mailer->IsSMTP();
  $mailer->Host = MAIL_HOST;
  if (MAIL_SMTP)
   {
     $mailer->SMTPAuth = MAIL_SMTP;
   }
      
   $mailer->Username = MAIL_USER; 
   $mailer->Password = MAIL_PASSWORD;
   $mailer->From = MAIL_FROM;
   $mailer->FromName = MAIL_NAME;
   $mailer->Body = $content;
   $mailer->Subject = $title;

   if ($to != '') {
        $mailer->AddAddress($to);
      }
      
   if (!$mailer->Send()) {
        echo $mailer->ErrorInfo;
      }
}

/**
 *
 * @param unknown_type $ttable 目标表
 * @param unknown_type $ftable   源表
 * @param unknown_type $fcondition  源条件
 * @param unknown_type $operate    操作人
 * @param unknown_type $odate      操作时间
 * @param unknown_type $oaction    操作动作
 */
   function operatebak($ttable,$ftable,$fcondition,$operate,$odate,$oaction)
   {
   	  global $myPdo;  
   	
   	  
   	  
   	  
   	 if($ftable == 'ns_v1purchaseitemselect')
   	 {
   	  $operate = empty($operate) ? '0':$operate;
      $sqlbak="INSERT INTO $ttable
               SELECT NULL,ft.*,'".$operate."' FROM $ftable AS ft WHERE $fcondition  ";   	 	
   	 }else{
   	  $sqlbak="INSERT INTO $ttable
               SELECT NULL,ft.*,'".$operate."','".$odate."','".$oaction."' FROM $ftable AS ft WHERE $fcondition  ";
   	 }
   	  sql_execute($sqlbak);
   	  $operateId = lastinsertid();
   	  
   	  return $operateId;
   }




 function customerno($customerId) {
  if ($customerId < 100000 && $customerId >= 10000) {
    $customerId = $customerId;
  } else if ($customerId < 10000 && $customerId >= 1000) {
    $customerId = '0'.$customerId;
  } else if ($customerId < 1000 && $customerId >= 100) {
    $customerId = '00'.$customerId;
  } if ($customerId < 100 && $customerId >= 10) {
    $customerId = '000'.$customerId;
  } if ($customerId < 10 && $customerId > 0) {
    $customerId = '0000'.$customerId;
  }
  return $customerId;
}

function todateobj($dateobj)
{
	if( is_object($dateobj) )
	{
	$dateobj->hours = 23;
	$dateobj->minutes = 59;
	$dateobj->seconds = 59;
	}
	return $dateobj;
	
}



/*
 * 读取数据并返回对象
 * 
 * */
function getall1($sql,$fetchmethod='')
{
	global $myPdo1;
	$data = array();
	
	$fetchmethod = empty($fetchmethod) ? PDO::FETCH_OBJ : PDO::FETCH_ASSOC ;
		
    $stmt2 = $myPdo1->prepare($sql);
    $stmt2->execute();

    while($tmp2 = $stmt2->fetch($fetchmethod)){
    	
    	foreach(array('date','createdDate','deadline','sentDate','receivedDate','when','cancelledDate','canceldate','operate_date') as $chdate)
    	{
	    		if(isset($tmp2->$chdate))
	    		{
	    			$tmp2->$chdate = ($tmp2->$chdate != 0) ? SimpleDate::fromStamp($tmp2->$chdate) : NULL;
	    		}
    		
    	}
    	
      	$data[] = $tmp2;
      }

      return $data;
}

/**
 * 读取producttrack的date,并返回
 */
function gettrackdate($produce_id,$targetid)
{
	global $myPdo1;
	
	$sql = "SELECT date FROM ns_producetrack WHERE produce_id in (".$produce_id.") AND targetId = ".$targetid." ORDER BY date DESC LIMIT 1";
	
	$tarckarr = getone1($sql);
	
	return  $tarckarr->date;
	
}

/**
 * 发送邮件带附件功能2013年5月6日 15:59:10
 * @param $to
 * @param $title
 * @param $content
 */
function resendEmail($to,$title,$content,$cusno,$attachname,$account,$cnow,$typeid,$orderid='')
{
  require_once dirname(__FILE__) . '/../library/phpMailer/class.phpmailer.php';
	

  $mailer = new PHPMailer();
  $path = dirname(__FILE__) . '/../mpdf/files/'.$cusno.'/'.$attachname;
  
  $mailer->IsSMTP();
  $mailer->Host = "localhost";
  /*if (true)
   {
     $mailer->SMTPAuth = true;
   }*/
      
   $mailer->Username = "dreamlif"; 
   $mailer->Password = "Wg6N4ORoIn+=";
   $mailer->From = MAIL_FROM1;
   $mailer->FromName = MAIL_NAME1;
   $mailer->Body = $content;
   $mailer->Subject = $title;
   
   if(!empty($attachname)){
      $mailer->AddAttachment($path, $attachname);
   }

   if ($to != '')  $mailer->AddAddress($to);
      
   if (!$mailer->Send()) {
        echo $mailer->ErrorInfo;
                $mailer->Body = addslashes($mailer->Body);
                $mailer->Subject = addslashes($mailer->Subject);
                $mailer->ErrorInfo = addslashes($mailer->ErrorInfo);
                $insql = "INSERT INTO ns_emailhistory(`e_oid`,`emailto`,`emailfrom`,`account`,`createdDate`,`subject`,`bodytext`,`attach`,`info`,`customerid`,`typeid`) 
                     values(NULL,'".$to."','".$mailer->From."','".$account."','".$cnow."','".$mailer->Subject."','".$mailer->Body."','".$attachname."','".$mailer->ErrorInfo."','".$cusno."','".$typeid."')";
                sql_execute($insql);
      }else{
      	$mailer->Body = addslashes($mailer->Body);
        $mailer->Subject = addslashes($mailer->Subject);
        $mailer->ErrorInfo = addslashes($mailer->ErrorInfo);      	
        $insql = "INSERT INTO ns_emailhistory(`e_oid`,`emailto`,`emailfrom`,`account`,`createdDate`,`subject`,`bodytext`,`attach`,`info`,`customerid`,`typeid`) 
                     values(NULL,'".$to."','".$mailer->From."','".$account."','".$cnow."','".$mailer->Subject."','".$mailer->Body."','".$attachname."','OK','".$cusno."','".$typeid."')";
       
        sql_execute($insql);      	
        
        if(!empty($orderid) && $typeid == 3){//把orderid的发送状态改成2，即已经发送过precon邮件
        	$myorder = "update ns_v1myorder set isemail=2 where e_oid = ".$orderid." ";
        	sql_execute($myorder);
        }
      }
}


 function getsecondpayment($orderid){
 	
      $sql = "select * from ns_v1myorder where e_oid =".$orderid." ";
   	  
   	  $tmporder = getone($sql);
   	  
   	  
          $tmporder->payments = array();
          $payment = getsonall('ns_v1payment','orderId',$orderid); 
          $tmporder->payments = $payment;
          
          $sqlpaym="SELECT SUM(amount) AS amount,orderId,customerId,`date`,stage,cancelled FROM ns_v1payment WHERE orderId=".$orderid." GROUP BY trackId,orderId";
          $paytmp=getall($sqlpaym);
          $tmporder->pays = $paytmp;          
          
          $tmporder->expense = array();
          
          $sqlex="SELECT * FROM ns_expense WHERE particular ='refund' AND refundNo = ".$orderid." ";
          $extmp=getall($sqlex);
          $tmporder->expense = $extmp;

          /*客人的payment总计*/
	  	  $otprice = 0 ;
	  	  $otpay   = 0 ;
	  	  $otex    = 0 ;
	  	  
	  	  
 	         //已经收款
	         $mpayo = $tmporder->payments;
	         $sumrec = 0;$stage = 0;$itotal1 = 0;$itotal2 = 0;$itotal3 = 0;$itotal4 = 0;
	         if(!empty($mpayo)){
	         	foreach($mpayo as $mpo){
	         		if($mpo->cancelled == 1 || $mpo->orderId != $orderid) continue;
	         		   $otpay +=$mpo->amount;
	         		   
	         		   if ($mpo->stage == 1) $itotal1 += $mpo->amount;
	                   if ($mpo->stage == 2) $itotal2 += $mpo->amount;
	                   if ($mpo->stage == 3) $itotal3 += $mpo->amount;
	                   if ($mpo->stage == 4) $itotal4 += $mpo->amount;
	                   
	                   $stage = max($stage, $mpo->stage);
	         	}
	         }

	         
 	         //退款
	         $expo = $tmporder->expense;
	         if(!empty($expo)){
	         	foreach ($expo as $eoo){
	         	    if($eoo->status == '-1' || $eoo->refundNo != $orderid) continue;
	         	       $otex +=$eoo->amount;
	         	}
	         }
	$oytpay = $otpay - $otex;//已经收减去已经退
    $ocpay = $otprice*(1+ GST) - $oytpay;//还没有收的
    
    $rule =  payment($tmporder->type);
    
 	  	  if ($rule[$stage]) {
		      $due = sprintf("%.2f",$tmporder->price*(1+ GST)*$rule[$stage]['rate'] - $otpay + $otex);
	      } else {
	    	  $due = sprintf("%.2f",$tmporder->price*(1+ GST) - $otpay + $otex);
	      }

	      
	return $due;      
 }
 
 
 
 /**
  * 获取每个阶段的付款和付款比例
  * @param $type
  */
 function payment($type)
 {
 	 $type = strtolower($type);
 	 
	 if($type == 'wedding')
	 {
		 return array( array( 'rate' => WEDDING_PAYMENT_RATE1, 'perc' =>  WEDDING_PAYMENT_PERC1, 'title' =>  WEDDING_PAYMENT_TITLE1, 'comment' =>  WEDDING_PAYMENT_COMMENT1,),
		          array( 'rate' =>  WEDDING_PAYMENT_RATE2, 'perc' =>  WEDDING_PAYMENT_PERC2, 'title' =>  WEDDING_PAYMENT_TITLE2, 'comment' =>  WEDDING_PAYMENT_COMMENT2,),
		          array( 'rate' =>  WEDDING_PAYMENT_RATE3, 'perc' =>  WEDDING_PAYMENT_PERC3, 'title' =>  WEDDING_PAYMENT_TITLE3, 'comment' =>  WEDDING_PAYMENT_COMMENT3,),
		          array( 'rate' =>  WEDDING_PAYMENT_RATE4, 'perc' =>  WEDDING_PAYMENT_PERC4, 'title' =>  WEDDING_PAYMENT_TITLE4, 'comment' =>  WEDDING_PAYMENT_COMMENT4,)
		        );
	 }else if($type == 'prewedding'){
			 return array( array( 'rate' =>  PREWEDDING_PAYMENT_RATE1, 'perc' =>  PREWEDDING_PAYMENT_PERC1, 'title' =>  PREWEDDING_PAYMENT_TITLE1, 'comment' =>  PREWEDDING_PAYMENT_COMMENT1,),
			          array( 'rate' =>  PREWEDDING_PAYMENT_RATE2, 'perc' =>  PREWEDDING_PAYMENT_PERC2, 'title' =>  PREWEDDING_PAYMENT_TITLE2, 'comment' =>  PREWEDDING_PAYMENT_COMMENT2,)
			         );
	 }else if($type == 'engagement'){
			 return array( array( 'rate' =>  ENGAGEMENT_PAYMENT_RATE1, 'perc' =>  ENGAGEMENT_PAYMENT_PERC1, 'title' =>  ENGAGEMENT_PAYMENT_TITLE1, 'comment' =>  ENGAGEMENT_PAYMENT_COMMENT1,),
			          array( 'rate' =>  ENGAGEMENT_PAYMENT_RATE2, 'perc' =>  ENGAGEMENT_PAYMENT_PERC2, 'title' =>  ENGAGEMENT_PAYMENT_TITLE2, 'comment' =>  ENGAGEMENT_PAYMENT_COMMENT2,)
			         );
	 }else if($type == 'portrait'){
			 return array( array( 'rate' =>  PORTRAIT_PAYMENT_RATE1, 'perc' =>  PORTRAIT_PAYMENT_PERC1, 'title' =>  PORTRAIT_PAYMENT_TITLE1, 'comment' =>  PORTRAIT_PAYMENT_COMMENT1,),
			          array('rate' =>  PORTRAIT_PAYMENT_RATE2, 'perc' =>  PORTRAIT_PAYMENT_PERC2, 'title' =>  PORTRAIT_PAYMENT_TITLE2, 'comment' =>  PORTRAIT_PAYMENT_COMMENT2,)
			        );
	}else if($type == 'other'){
			 return array( array( 'rate' =>  OTHER_PAYMENT_RATE1, 'perc' =>  OTHER_PAYMENT_PERC1, 'title' =>  OTHER_PAYMENT_TITLE1, 'comment' =>  OTHER_PAYMENT_COMMENT1,)
			        );
	}

 }














?>